package com.ymatou.iapi.trading.sellerquery2.testcase;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.stream.Collectors;

import org.apache.commons.collections.CollectionUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.trading.operate.parameter.Order;
import com.ymatou.iapi.trading.operate.parameter.OrderItemVo;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderResp;
import com.ymatou.iapi.trading.operate.parameter.PlaceOrderService;
import com.ymatou.iapi.trading.operate.parameter.SellerPromotionVo;
import com.ymatou.iapi.trading.operate.parameter.enums.PromotionTypeEnum;
import com.ymatou.iapi.trading.operate.parameter.po.OrderInfoSubPo;
import com.ymatou.iapi.trading.operate.parameter.po.SubcatalogsPo;
import com.ymatou.iapi.trading.operate.parameter.req.PlaceOrderReq;
import com.ymatou.iapi.trading.ordersync.service.SyncVerifyService;
import com.ymatou.iapi.trading.sellerquery2.parameter.resp.SubProductInfo;
import com.ymatou.iapi.trading.sellerquery2.parameter.sp.Sp_GetBondedProductInfo;
import com.ymatou.query.seller.trading.api.parameter.Common;
import com.ymatou.query.trading.api.parameter.GetBondedProductInfoBean;
import com.ymatou.query.trading.api.parameter.resp.GetBondedProductInfoResp;
import com.ymatou.query.trading.api.parameter.results.GetBondedProductInfoResult;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.OrderCallService;
import com.ymttest.business.service.PaymentProxyCallService;
import com.ymttest.common.entitie.BondedProductInfo;
import com.ymttest.common.enums.BondedAreaEnum;
import com.ymttest.common.enums.LogisticsTypeEnum;
import com.ymttest.common.enums.OrderStatusEnum;
import com.ymttest.database.sqlwapper.DefaultWapper;
import com.ymttest.database.sqlwapper.YmtProductsIWapper;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.YMTDateUtil;
import com.ymttest.utils.constant.ECode;

/**
 * 获取保税商品信息 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_GetBondedProductInfo {

	private static GetBondedProductInfoBean request;
	//	private static com.ymatou.query.trading.api.service.GetBondedProductInfoCall getbondedproductinfocall;
	private static com.ymatou.iapi.trading.sellerquery2.service.GetBondedProductInfoCall getbondedproductinfocall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取保税商品信息");
	}

	@Before
	public void caseUp() {
		request = new GetBondedProductInfoBean();
		//		getbondedproductinfocall = new com.ymatou.query.trading.api.service.GetBondedProductInfoCall();
		getbondedproductinfocall = new com.ymatou.iapi.trading.sellerquery2.service.GetBondedProductInfoCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getbondedproductinfocall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	/**
	 * 
	 * 下单含有组合商品，使用优惠券，商家优惠,保税发货
	 *
	 */
	private static PlaceOrderResp placeOrder10() {

		PlaceOrderReq placeorderBean = PlaceOrderService.getDefaultOrderReq();

		SubcatalogsPo subcatalogsPo = null, subcatalogsPo2 = null;
		try {

			subcatalogsPo = new YmtProductsIWapper().getSubcatalogs();

			subcatalogsPo2 = new YmtProductsIWapper().getSubcatalogs();

		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		//组合商品
		String catalogId = subcatalogsPo.getCatalogId();

		placeorderBean = PlaceOrderService.getDefaultOrderReq();

		OrderItemVo OrderItemVo = placeorderBean.getOrderGroups().get(0)
				.getOrders().get(0).getOrderItems().get(0);

		OrderItemVo
				.setBondedArea(com.ymatou.iapi.trading.operate.parameter.enums.BondedAreaEnum.TianJin);

		OrderItemVo
				.setLogisticsType(com.ymatou.iapi.trading.operate.parameter.enums.LogisticsTypeEnum.BondedDelivery);

		OrderItemVo.setCatalogId(catalogId);

		OrderItemVo.setSubProduct(true);

		OrderItemVo.setFreight(new BigDecimal(new Random().nextInt(100)));

		OrderItemVo OrderItemVo2 = PlaceOrderService.getDefaultOrderItemVo();

		OrderItemVo2.setCatalogId(subcatalogsPo2.getCatalogId());

		OrderItemVo2.setFreight(new BigDecimal(new Random().nextInt(100)));

		OrderItemVo2.setSubProduct(true);

		OrderItemVo2
				.setBondedArea(com.ymatou.iapi.trading.operate.parameter.enums.BondedAreaEnum.TianJin);

		OrderItemVo2
				.setLogisticsType(com.ymatou.iapi.trading.operate.parameter.enums.LogisticsTypeEnum.BondedDelivery);

		placeorderBean.getOrderGroups().get(0).getOrders().get(0)
				.getOrderItems().add(OrderItemVo2);

		// 定义买手下的优惠商品信息list
		List<SellerPromotionVo> sellerPromotionList = new ArrayList<SellerPromotionVo>();

		SellerPromotionVo sellerPromotion1 = new SellerPromotionVo();
		sellerPromotion1.setAmountCondition(new BigDecimal(20));
		sellerPromotion1.setId(123456789);
		sellerPromotion1.setName("自动化商家优惠活动");
		Set<String> productList = new HashSet<String>();
		productList.add(OrderItemVo.getProductId());
		sellerPromotion1.setProductIds(productList);
		sellerPromotion1.setPromotionValue(new BigDecimal(12));
		sellerPromotion1.setQtyCondition(4);
		sellerPromotion1.setReducedAmount(new BigDecimal(15));
		sellerPromotion1.setType(PromotionTypeEnum.DiscountIfCountEnough);

		sellerPromotionList.add(sellerPromotion1);

		placeorderBean.getOrderGroups().get(0)
				.setSellerPromotions(sellerPromotionList);

		return PlaceOrderService.callPlaceOrderService(placeorderBean);
	}
	private void verify() {
		GetBondedProductInfoResp expectResponse = new GetBondedProductInfoResp();

		ConstructExpectedResponse(expectResponse);

		GetBondedProductInfoResp actualResponse = getbondedproductinfocall
				.getBondedProductInfoResp();
		List<BondedProductInfo> expects = expectResponse
				.getBondedProductInfoList();

		List<BondedProductInfo> actuals = actualResponse
				.getBondedProductInfoList();
		if (DataUtil.isNullOrEmpty(expects)) {
			DataUtil.verify(true, DataUtil.isNullOrEmpty(actuals),
					"验证BondedProductInfoList == null或size()==0");
		} else {
			boolean hasValue = DataUtil.isNullOrEmpty(actuals) == false;
			DataUtil.verify(true, hasValue,
					"验证BondedProductInfoList != null且size()>0");
			if (hasValue) {
				boolean sameSize = expects.size() == actuals.size();
				DataUtil.verify(expects.size(), actuals.size(),
						"验证BondedProductInfoList.size()");
				if (sameSize) {
					for (BondedProductInfo expect : expects) {
						boolean exist = actuals.stream().anyMatch(
								x -> x.getOrderNo() == expect.getOrderNo()
										&& x.getCatalogId().equals(
												expect.getCatalogId()));
						DataUtil.verify(true, exist, "验证期望的: orderno = "
								+ expect.getOrderNo() + ", 且CatalogId = "
								+ expect.getCatalogId()
								+ "的BondedProductInfo对象在BondedProductInfoList中");
						int t = actuals
								.stream()
								.filter(x -> x.getOrderNo() == expect
										.getOrderNo()
										&& x.getCatalogId().equals(
												expect.getCatalogId()))
								.collect(Collectors.toList()).size();
						boolean distinctRecord = t == 1;
						DataUtil.verify(
								true,
								distinctRecord,
								"验证期望的: orderno = "
										+ expect.getOrderNo()
										+ ", 且CatalogId = "
										+ expect.getCatalogId()
										+ "的BondedProductInfo对象在BondedProductInfoList中是唯一的记录");
						if (exist && distinctRecord) {
							BondedProductInfo actual = actuals
									.stream()
									.filter(x -> x.getOrderNo() == expect
											.getOrderNo()
											&& x.getCatalogId().equals(
													expect.getCatalogId()))
									.collect(Collectors.toList()).get(0);
							verifyBondedProductInfo(expect, actual,
									expect.getOrderNo(), expect.getCatalogId());
						}
					}
				}
			}
		}
	}

	private void verifyBondedProductInfo(BondedProductInfo exp,
			BondedProductInfo act, int orderno, String cid) {

		DataUtil.verify(exp.getAddress(), act.getAddress(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.Address");
		DataUtil.verify(exp.getAddTime(), act.getAddTime(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.AddTime");
		DataUtil.verify(exp.getBondedArea(), act.getBondedArea(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.BondedArea");
		DataUtil.verify(exp.getBondedAreaId(), act.getBondedAreaId(),
				"验证orderNo=[" + orderno + "],且catalogid=[" + cid
						+ "]的BondedProductInfo.BondedAreaId");
		DataUtil.verify(exp.getBuyerLoginId(), act.getBuyerLoginId(),
				"验证orderNo=[" + orderno + "],且catalogid=[" + cid
						+ "]的BondedProductInfo.BuyerLoginId");
		DataUtil.verify(exp.getBuyerName(), act.getBuyerName(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.BuyerName");
		DataUtil.verify(exp.getBuyerPhone(), act.getBuyerPhone(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.BuyerPhone");
		DataUtil.verify(exp.getCatalogId(), act.getCatalogId(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.CatalogId");
		DataUtil.verify(exp.getCatalogInfo(), act.getCatalogInfo(),
				"验证orderNo=[" + orderno + "],且catalogid=[" + cid
						+ "]的BondedProductInfo.CatalogInfo");
		DataUtil.verify(exp.getCity(), act.getCity(), "验证orderNo=[" + orderno
				+ "],且catalogid=[" + cid + "]的BondedProductInfo.City");
		DataUtil.verify(exp.getCounty(), act.getCounty(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.County");
		DataUtil.verify(exp.getExpressCompany(), act.getExpressCompany(),
				"验证orderNo=[" + orderno + "],且catalogid=[" + cid
						+ "]的BondedProductInfo.ExpressCompany");
		DataUtil.verify(exp.getFreight(), act.getFreight(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.Freight");
		// DataUtil.verify(exp.isIsPaidInFull(),
		// act.isIsPaidInFull(),"验证orderNo=["+orderno+"],且catalogid=[" + cid +
		// "]的BondedProductInfo.IsPaidInFull");
		DataUtil.verify(exp.getLeaveWord(), act.getLeaveWord(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.LeaveWord");
		DataUtil.verify(exp.getOrderNo(), act.getOrderNo(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.OrderNo");
		DataUtil.verify(DataUtil.Stringg.getValueOrDefault(exp.getOrderNote()),
				DataUtil.Stringg.getValueOrDefault(act.getOrderNote()),
				"验证orderNo=[" + orderno + "],且catalogid=[" + cid
						+ "]的BondedProductInfo.OrderNote");
		DataUtil.verify(exp.getOrderState(), act.getOrderState(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.OrderState");
		DataUtil.verify(exp.getPaySerialNo(), act.getPaySerialNo(),
				"验证orderNo=[" + orderno + "],且catalogid=[" + cid
						+ "]的BondedProductInfo.PaySerialNo");
		DataUtil.verify(exp.getPayType(), act.getPayType(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.PayType");
		DataUtil.verify(exp.getPhone(), act.getPhone(), "验证orderNo=[" + orderno
				+ "],且catalogid=[" + cid + "]的BondedProductInfo.Phone");
		DataUtil.verify(exp.getPostCode(), act.getPostCode(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.PostCode");
		DataUtil.verify(
				DataUtil.Stringg.getValueOrDefault(exp.getProductCode()),
				DataUtil.Stringg.getValueOrDefault(act.getProductCode()),
				"验证orderNo=[" + orderno + "],且catalogid=[" + cid
						+ "]的BondedProductInfo.ProductCode");
		DataUtil.verify(exp.getProductName(), act.getProductName(),
				"验证orderNo=[" + orderno + "],且catalogid=[" + cid
						+ "]的BondedProductInfo.ProductName");
		DataUtil.verify(exp.getProductNo(), act.getProductNo(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.ProductNo");
		DataUtil.verify(exp.getProductNum(), act.getProductNum(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.ProductNum");
		DataUtil.verify(exp.getProductPrice(), act.getProductPrice(),
				"验证orderNo=[" + orderno + "],且catalogid=[" + cid
						+ "]的BondedProductInfo.ProductPrice");
		DataUtil.verify(exp.getProductRegisterNo(), act.getProductRegisterNo(),
				"验证orderNo=[" + orderno + "],且catalogid=[" + cid
						+ "]的BondedProductInfo.ProductRegisterNo");
		DataUtil.verify(exp.getProductSku(), act.getProductSku(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.ProductSku");
		DataUtil.verify(exp.getProvince(), act.getProvince(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.Province");
		// DataUtil.verify(exp.getReceiveEmail(),
		// act.getReceiveEmail(),"验证orderNo=["+orderno+"],且catalogid=[" + cid +
		// "]的BondedProductInfo.ReceiveEmail");
		DataUtil.verify(exp.getReceivePerson(), act.getReceivePerson(),
				"验证orderNo=[" + orderno + "],且catalogid=[" + cid
						+ "]的BondedProductInfo.ReceivePerson");
		//		DataUtil.verify(exp.getReceiverCertificateNo(), act.getReceiverCertificateNo(), "验证orderNo=[" + orderno
		//						+ "],且catalogid=[" + cid + "]的BondedProductInfo.ReceiverCertificateNo");
		DataUtil.verify(exp.getRiskVerifiedStatus(),
				act.getRiskVerifiedStatus(), "验证orderNo=[" + orderno
						+ "],且catalogid=[" + cid
						+ "]的BondedProductInfo.RiskVerifiedStatus");
		DataUtil.verify(exp.getSellerCouponAmount(),
				act.getSellerCouponAmount(), "验证orderNo=[" + orderno
						+ "],且catalogid=[" + cid
						+ "]的BondedProductInfo.SellerCouponAmount");
		DataUtil.verify(exp.getTelephone(), act.getTelephone(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.Telephone");
		DataUtil.verify(exp.getTotalPrice(), act.getTotalPrice(), "验证orderNo=["
				+ orderno + "],且catalogid=[" + cid
				+ "]的BondedProductInfo.TotalPrice");

		//校验组合商品
		verifySubProducts(orderno, cid, act);

	}
	/**
	 * 校验组合商品
	 * @param expectId
	 * @param actProducts
	 */
	private static void verifySubProducts(int orderId, String catalogId,
			BondedProductInfo actProduct) {

		DefaultWapper data = new DefaultWapper();

		try {

			List<SubProductInfo> actualOrderInfoSub = actProduct
					.getSubProductInfos();

			List<OrderInfoSubPo> expectOrderInfoSub = data.getOrderInfoSub(
					orderId, catalogId);

			if (!CollectionUtils.isEmpty(expectOrderInfoSub)) {

				DataUtil.verifyEquals(expectOrderInfoSub.size(),
						actualOrderInfoSub.size(), "验证id=[" + orderId
								+ "]Products 下组合商品记录数");

				boolean flag = expectOrderInfoSub.size() == actualOrderInfoSub
						.size();

				if (flag) {
					Logger.comment("开始验证catalogId=[" + catalogId
							+ "]的Products下的组合商品");

					for (int i = 0; i < expectOrderInfoSub.size(); i++) {

						OrderInfoSubPo expect = expectOrderInfoSub.get(i);
						SubProductInfo actual = actualOrderInfoSub.get(i);

						Logger.verifyEquals(expect.getSubTitle(),
								actual.getSubTitle(), "校验组合商品 subTitle");
						Logger.verifyEquals(expect.getSubCatalogId(),
								actual.getSubCatalogId(), "校验组合商品 subCatalogId");
						Logger.verifyEquals(expect.getFirstCatId(),
								actual.getFirstCatId(), "校验组合商品 firstCatId");

						Logger.verifyEquals(expect.getSecondCatId(),
								actual.getSecondCatId(), "校验组合商品 secondCatId");

						Logger.verifyEquals(expect.getThirdCatId(),
								actual.getThirdCatId(), "校验组合商品 thirdCatId");

						Logger.verifyEquals(expect.getNum(), actual.getNum(),
								"校验组合商品 num");

						DataUtil.verifyDecimalEquals(expect.getOriginalPrice(),
								actual.getOriginalPrice(),
								"校验组合商品 originalPrice");

						DataUtil.verifyDecimalEquals(expect.getPrice(),
								actual.getPrice(), "校验组合商品 price");

						DataUtil.verifyDecimalEquals(expect.getFreight(),
								actual.getFreight(), "校验组合商品 freight");

						DataUtil.verifyDecimalEquals(expect.getDiscount(),
								actual.getDiscount(), "校验组合商品 discount");

						DataUtil.verifyDecimalEquals(expect.getYmtCoupon(),
								actual.getYmtCoupon(), "校验组合商品 ymtCoupon");

						DataUtil.verifyDecimalEquals(expect.getSellerCoupon(),
								actual.getSellerCoupon(), "校验组合商品 sellerCoupon");

						DataUtil.verifyDecimalEquals(
								expect.getThirdPartyDiscount(),
								actual.getThirdPartyDiscount(),
								"校验组合商品 thirdPartyDiscount");

						DataUtil.verifyDecimalEquals(expect.getPromotion(),
								actual.getPromotion(), "校验组合商品 promotion");

					}

				}
			}

		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	@SuppressWarnings("rawtypes")
	private void ConstructExpectedResponse(GetBondedProductInfoResp response) {
		Map<String, List<Map>> results = execute();
		GetBondedProductInfoResult result = ConvertResult(results);
		List<GetBondedProductInfoResult.YmtOrderInfo> orderInfos = result
				.getOrderInfos();
		List<BondedProductInfo> bondedProductInfoList = new ArrayList<BondedProductInfo>();
		orderInfos.forEach(x -> bondedProductInfoList
				.add(ConvertOrderInfoToBondedProductInfo(x)));
		//		changeTradingId(bondedProductInfoList);
		response.setBondedProductInfoList(bondedProductInfoList);
	}

	//	@SuppressWarnings("rawtypes")
	//	private void changeTradingId(List<BondedProductInfo> bondedProductInfoList) {
	//		if (DataUtil.isNullOrEmpty(bondedProductInfoList))
	//			return;
	//
	//		int[] orderIds = bondedProductInfoList.stream().mapToInt(x -> x.getOrderNo()).toArray();
	//		String orderIdString = "(";
	//		for (int i = 0; i < orderIds.length; i++) {
	//			orderIdString += orderIds[i];
	//			if (i < orderIds.length - 1) {
	//				orderIdString += ",";
	//			}
	//		}
	//		orderIdString += ")";
	//
	//		List<Map> tradingIds = new DefaultWapper()
	//						.executeSql("select iOrderId,isnull(o.iTradingId,o.iMainOrderId) as tradingId from ymt_orders o where o.iOrderId in "
	//										+ orderIdString);
	//		for (BondedProductInfo o : bondedProductInfoList) {
	//			int tradingId = (int) tradingIds.stream().filter(x -> (int) x.get("iOrderId") == o.getOrderNo())
	//							.collect(Collectors.toList()).get(0).get("tradingId");
	//			o.setPaySerialNo(String.valueOf(tradingId));
	//		}
	//	}

	private String getPayType(GetBondedProductInfoResult.YmtTradingInfo info) {
		if (null == info)
			return "";
		String channel = info.getsPayChannel();
		if (DataUtil.Stringg.isNullOrEmpty(channel)) {
			return "";
		}
		if (channel.equalsIgnoreCase("Weixin")) {
			return "微信";
		}
		if (channel.equalsIgnoreCase("Alipay")) {
			return "支付宝";
		}
		return "";
	}

	private BondedProductInfo ConvertOrderInfoToBondedProductInfo(
			GetBondedProductInfoResult.YmtOrderInfo oi) {
		GetBondedProductInfoResult.YmtOrder order = oi.getOrder();
		GetBondedProductInfoResult.YmtOrderSummary orderSummary = order
				.getYmt_OrderSummary();
		GetBondedProductInfoResult.YmtUser buyer = order.getYmt_User();
		if (buyer == null) {
			buyer = new GetBondedProductInfoResult.YmtUser();
		}

		int tradingId = order.getTradingItem() == null ? 0 : order
				.getTradingItem().getiTradingId();

		GetBondedProductInfoResult.YmtIdPic idPic = order.getIdPic();
		String[] addressArray = order.getsAddress().split(",");

		String strBonderArea = DataUtil.Stringg.Empty;
		if (oi.getiBondedArea() != null) {
			int i = oi.getiBondedArea();
			if (i == BondedAreaEnum.GuangZhou.getValue()) {
				strBonderArea = "广州保税区";
			} else if (i == BondedAreaEnum.NingBo.getValue()) {
				strBonderArea = "宁波保税区";
			}
		}

		BondedProductInfo bondedProductInfo = new BondedProductInfo();
		bondedProductInfo.setOrderNo(order.getiOrderId());
		bondedProductInfo.setOrderNote(order.getYmt_O_OrderNote() != null
				? order.getYmt_O_OrderNote().getsContent()
				: DataUtil.Stringg.Empty);
		bondedProductInfo.setLeaveWord(order.getsLeaveWord());
		bondedProductInfo.setTelephone(order.getsTelephone());
		bondedProductInfo.setAddTime(order.getdAddTime());
		bondedProductInfo
				.setOrderState(Common.GetOrderStatusForSeller(
						order.getiTradingStatus(),
						order.getiRiskVerifiedStatus(), null));
		bondedProductInfo.setRiskVerifiedStatus(order.getiRiskVerifiedStatus());
		bondedProductInfo.setIsPaidInFull(order.isbPaidInFull());
		bondedProductInfo.setBuyerLoginId(order.getsBuyerLoginId());
		bondedProductInfo.setBuyerPhone(order.getsPhone());
		bondedProductInfo.setBuyerName("");
		bondedProductInfo.setReceivePerson(order.getsReceivePerson());
		bondedProductInfo.setReceiveEmail(order.getsEmail() == null ? order
				.getsBuyerLoginEmail() : "");
		bondedProductInfo.setTotalPrice(order.GetCurrentAmountOfCash());
		bondedProductInfo.setPhone(order.getsPhone());
		bondedProductInfo.setReceiverCertificateNo(idPic != null ? idPic
				.getsCardId() : "");
		bondedProductInfo.setProvince(addressArray.length >= 1
				? addressArray[0]
				: "");
		bondedProductInfo.setCity(addressArray.length >= 2
				? addressArray[1]
				: "");
		bondedProductInfo.setCounty(addressArray.length >= 3
				? addressArray[2]
				: "");
		bondedProductInfo.setAddress(order.getsAddress());
		bondedProductInfo.setPostCode(order.getsPostCode());
		bondedProductInfo.setProductName(oi.getsTitle().replaceAll("？", ""));
		bondedProductInfo.setFreight(order.getfFreight());
		bondedProductInfo.setProductNum(oi.getiAmount());
		bondedProductInfo.setProductPrice(oi.getfOriginalPrice());
		bondedProductInfo.setBondedArea(strBonderArea);
		bondedProductInfo.setBondedAreaId(oi.getiBondedArea() != null ? oi
				.getiBondedArea() : 0);
		bondedProductInfo.setProductRegisterNo(oi.getsProductCode());
		bondedProductInfo.setPayType(getPayType(order.getTradingItem()
				.getYmt_TradingInfo()));
		bondedProductInfo.setPaySerialNo(tradingId != 0 ? String
				.valueOf(tradingId) : "");
		bondedProductInfo.setExpressCompany(orderSummary != null ? orderSummary
				.getsLogisticsProvider() : "");
		bondedProductInfo.setProductNo(oi.getsProductId());
		bondedProductInfo.setProductSku(oi.getsSKU());
		bondedProductInfo.setProductCode(GetSku(oi.getsSKU()));
		bondedProductInfo.setCatalogId(oi.getsCatalogId());

		bondedProductInfo.setCatalogInfo("");
		if (!DataUtil.Stringg.isNullOrEmpty(oi.getsPropertyInfo())) {
			List<String> propertyList = new ArrayList<String>();
			if (oi.getsPropertyInfo().contains(",")) {
				String[] arr = oi.getsPropertyInfo().split(",");
				for (String s : arr) {
					propertyList.add(s);
				}
			} else {
				propertyList.add(oi.getsPropertyInfo());
			}
			StringBuilder strProperty = new StringBuilder();

			propertyList.forEach(z -> {
				String strSecondProperty = z.substring(z.lastIndexOf(":") + 1);
				if (strSecondProperty.contains("#")) {
					strProperty.append(
							strSecondProperty.substring(strSecondProperty
									.lastIndexOf("#") + 1)).append(":");
				} else {
					strProperty.append(strSecondProperty).append(":");
				}
			});
			String str = strProperty.toString();
			if (!DataUtil.Stringg.isNullOrEmpty(str)) {
				if (str.charAt(str.length() - 1) == ':') {
					str = str.substring(0, str.length() - 1);
				}
			}
			bondedProductInfo.setCatalogInfo(str);
		}

		return bondedProductInfo;
	}

	private static String GetSku(String s) {
		if (DataUtil.Stringg.IsNullOrWhiteSpace(s))
			return DataUtil.Stringg.Empty;

		int i = s.indexOf(":");
		if (i > -1) {
			return s.substring(0, i);
		}
		return s;
	}

	@SuppressWarnings("rawtypes")
	private Map<String, List<Map>> execute() {
		Sp_GetBondedProductInfo sp = new Sp_GetBondedProductInfo();
		// 存储过程的变量赋值
		BuildArguments(sp);
		return sp.execute();
	}

	@SuppressWarnings("rawtypes")
	private GetBondedProductInfoResult ConvertResult(
			Map<String, List<Map>> results) {
		GetBondedProductInfoResult result = new GetBondedProductInfoResult();
		List<GetBondedProductInfoResult.YmtOrder> orders = null;
		List<GetBondedProductInfoResult.YmtOrderInfo> orderInfos = null;
		List<GetBondedProductInfoResult.YmtTradingItem> tradingItems = null;
		List<GetBondedProductInfoResult.YmtTradingInfo> tradingInfos = null;
		List<GetBondedProductInfoResult.YmtOrderState> orderStates = null;
		List<GetBondedProductInfoResult.YmtUser> users = null;
		List<GetBondedProductInfoResult.YmtIdPic> pics = null;
		List<GetBondedProductInfoResult.YmtOrderNote> orderNotes = null;
		List<GetBondedProductInfoResult.YmtOrderSummary> orderSummaries = null;

		if (results != null && results.size() > 0) {
			List<Map> orderList = results.get("orders");
			if (!DataUtil.isNullOrEmpty(orderList)) {
				orders = new ArrayList<GetBondedProductInfoResult.YmtOrder>();
				for (Map m : orderList) {
					GetBondedProductInfoResult.YmtOrder o = new GetBondedProductInfoResult.YmtOrder();
					DataUtil.mapToBean(o, m);
					orders.add(o);
				}
			}

			List<Map> orderInfoList = results.get("orderInfos");
			if (!DataUtil.isNullOrEmpty(orderInfoList)) {
				orderInfos = new ArrayList<GetBondedProductInfoResult.YmtOrderInfo>();
				for (Map m : orderInfoList) {
					GetBondedProductInfoResult.YmtOrderInfo o = new GetBondedProductInfoResult.YmtOrderInfo();
					DataUtil.mapToBean(o, m);
					orderInfos.add(o);
				}
			}

			List<Map> tradingItemList = results.get("tradingItems");
			if (!DataUtil.isNullOrEmpty(tradingItemList)) {
				tradingItems = new ArrayList<GetBondedProductInfoResult.YmtTradingItem>();
				for (Map m : tradingItemList) {
					GetBondedProductInfoResult.YmtTradingItem o = new GetBondedProductInfoResult.YmtTradingItem();
					DataUtil.mapToBean(o, m);
					tradingItems.add(o);
				}
			}

			List<Map> tradingInfoList = results.get("tradingInfos");
			if (!DataUtil.isNullOrEmpty(tradingInfoList)) {
				tradingInfos = new ArrayList<GetBondedProductInfoResult.YmtTradingInfo>();
				for (Map m : tradingInfoList) {
					GetBondedProductInfoResult.YmtTradingInfo o = new GetBondedProductInfoResult.YmtTradingInfo();
					DataUtil.mapToBean(o, m);
					tradingInfos.add(o);
				}
			}

			List<Map> orderStateList = results.get("orderStates");
			if (!DataUtil.isNullOrEmpty(orderStateList)) {
				orderStates = new ArrayList<GetBondedProductInfoResult.YmtOrderState>();
				for (Map m : orderStateList) {
					GetBondedProductInfoResult.YmtOrderState o = new GetBondedProductInfoResult.YmtOrderState();
					DataUtil.mapToBean(o, m);
					orderStates.add(o);
				}
			}

			List<Map> userList = results.get("users");
			if (!DataUtil.isNullOrEmpty(userList)) {
				users = new ArrayList<GetBondedProductInfoResult.YmtUser>();
				for (Map m : userList) {
					GetBondedProductInfoResult.YmtUser o = new GetBondedProductInfoResult.YmtUser();
					DataUtil.mapToBean(o, m);
					users.add(o);
				}
			}

			List<Map> picList = results.get("pics");
			if (!DataUtil.isNullOrEmpty(picList)) {
				pics = new ArrayList<GetBondedProductInfoResult.YmtIdPic>();
				for (Map m : picList) {
					GetBondedProductInfoResult.YmtIdPic o = new GetBondedProductInfoResult.YmtIdPic();
					DataUtil.mapToBean(o, m);
					pics.add(o);
				}
			}

			List<Map> orderNoteList = results.get("orderNotes");
			if (!DataUtil.isNullOrEmpty(orderNoteList)) {
				orderNotes = new ArrayList<GetBondedProductInfoResult.YmtOrderNote>();
				for (Map m : orderNoteList) {
					GetBondedProductInfoResult.YmtOrderNote o = new GetBondedProductInfoResult.YmtOrderNote();
					DataUtil.mapToBean(o, m);
					orderNotes.add(o);
				}
			}

			List<Map> orderSummaryList = results.get("orderSummaries");
			if (!DataUtil.isNullOrEmpty(orderSummaryList)) {
				orderSummaries = new ArrayList<GetBondedProductInfoResult.YmtOrderSummary>();
				for (Map m : orderSummaryList) {
					GetBondedProductInfoResult.YmtOrderSummary o = new GetBondedProductInfoResult.YmtOrderSummary();
					DataUtil.mapToBean(o, m);
					orderSummaries.add(o);
				}
			}

		}
		result.setIdPics(GetIdPics(pics));
		result.setTradingItems(MergeTradingItem(tradingItems, tradingInfos));
		result.setOrders(MergeOrder(orders, orderStates, users, orderNotes,
				orderSummaries, pics, result.getTradingItems()));
		result.setOrderInfos(GetOrderInfos(orderInfos, orders));
		return result;
	}

	private List<GetBondedProductInfoResult.YmtOrderInfo> GetOrderInfos(
			List<GetBondedProductInfoResult.YmtOrderInfo> orderInfos,
			List<GetBondedProductInfoResult.YmtOrder> orders) {
		List<GetBondedProductInfoResult.YmtOrderInfo> s = new ArrayList<GetBondedProductInfoResult.YmtOrderInfo>();
		if (!DataUtil.isNullOrEmpty(orderInfos)) {
			for (GetBondedProductInfoResult.YmtOrderInfo item : orderInfos) {
				List<GetBondedProductInfoResult.YmtOrder> t = orders.stream()
						.filter(x -> x.getiOrderId() == item.getiOrderId())
						.collect(Collectors.toList());
				if (!DataUtil.isNullOrEmpty(t)) {
					item.setOrder(t.get(0));
				}
				s.add(item);
			}
		}
		return s;
	}

	private List<GetBondedProductInfoResult.YmtOrder> MergeOrder(
			List<GetBondedProductInfoResult.YmtOrder> orders,
			List<GetBondedProductInfoResult.YmtOrderState> orderStates,
			List<GetBondedProductInfoResult.YmtUser> users,
			List<GetBondedProductInfoResult.YmtOrderNote> orderNotes,
			List<GetBondedProductInfoResult.YmtOrderSummary> orderSummaries,
			List<GetBondedProductInfoResult.YmtIdPic> pics,
			List<GetBondedProductInfoResult.YmtTradingItem> items) {
		List<GetBondedProductInfoResult.YmtOrder> s = new ArrayList<GetBondedProductInfoResult.YmtOrder>();
		if (!DataUtil.isNullOrEmpty(orders)) {
			for (GetBondedProductInfoResult.YmtOrder item : orders) {
				int iOrderId = item.getiOrderId();
				int iUserId = item.getiUserId();

				// GetBondedProductInfoResult.YmtTradingItem i =
				// item.getTradingItem();
				GetBondedProductInfoResult.YmtTradingItem i = null;

				if (items.stream().anyMatch(x -> x.getiOrderId() == iOrderId)) {
					List<GetBondedProductInfoResult.YmtTradingItem> t = items
							.stream().filter(x -> x.getiOrderId() == iOrderId)
							.collect(Collectors.toList());
					i = t.stream()
							.sorted((a, b) -> b.getiTradingId()
									- a.getiTradingId())
							.collect(Collectors.toList()).get(0);
					// i =
					// items.stream().filter(x->x.getiOrderId()==iOrderId).collect(Collectors.toList()).get(0);
				}

				List<GetBondedProductInfoResult.YmtOrderState> orderStateList = orderStates
						.stream().filter(x -> x.getiOrderId() == iOrderId)
						.collect(Collectors.toList());
				if (!DataUtil.isNullOrEmpty(orderStateList)) {
					item.setYmt_OrderStates(orderStateList.get(0));
				}

				List<GetBondedProductInfoResult.YmtUser> userList = users
						.stream().filter(x -> x.getiUserId() == iUserId)
						.collect(Collectors.toList());
				if (!DataUtil.isNullOrEmpty(userList)) {
					item.setYmt_User(userList.get(0));
				}

				List<GetBondedProductInfoResult.YmtOrderNote> orderNoteList = null;
				if (!DataUtil.isNullOrEmpty(orderNotes)) {
					orderNoteList = orderNotes.stream()
							.filter(x -> x.getiOrderId() == iOrderId)
							.collect(Collectors.toList());
				}
				if (!DataUtil.isNullOrEmpty(orderNoteList)) {
					item.setYmt_O_OrderNote(orderNoteList.get(0));
				}

				List<GetBondedProductInfoResult.YmtOrderSummary> orderSummaryList = null;
				if (!DataUtil.isNullOrEmpty(orderSummaries)) {
					orderSummaryList = orderSummaries.stream()
							.filter(x -> x.getiOrderId() == iOrderId)
							.collect(Collectors.toList());
				}
				if (!DataUtil.isNullOrEmpty(orderSummaryList)) {
					item.setYmt_OrderSummary(orderSummaryList.get(0));
				}

				List<GetBondedProductInfoResult.YmtIdPic> picList = null;
				if (!DataUtil.isNullOrEmpty(pics)) {
					picList = pics.stream()
							.filter(x -> x.getiOrderId() == iOrderId)
							.collect(Collectors.toList());
				}
				if (!DataUtil.isNullOrEmpty(picList)) {
					item.setIdPic(picList.get(0));
				}

				if (i != null) {
					int tradingId = i.getiTradingId();
					List<GetBondedProductInfoResult.YmtTradingItem> itemList = items
							.stream()
							.filter(x -> x.getiTradingId() == tradingId
							// &&
							// (x.getYmt_TradingInfo().getiTradingStatus()
							// == 2 ||
							// isLater(x.getdUpdateTime(),item.getTradingItem()
							// ==
							// null?"":item.getTradingItem().getdUpdateTime()))
							).collect(Collectors.toList());
					if (!DataUtil.isNullOrEmpty(itemList)) {
						item.setTradingItem(itemList.get(0));
					}
				}
				s.add(item);
			}
		}

		return s;
	}

	private boolean isLater(String d1, String d2) {
		if (d1 == null || d1 == "") {
			d1 = DataUtil.defaultJavaDateString;
		}
		if (d2 == null || d2 == "") {
			d2 = DataUtil.defaultJavaDateString;
		}
		int i = YMTDateUtil.parseDate(d1, YMTDateUtil.YMDHMS).compareTo(
				YMTDateUtil.parseDate(d2, YMTDateUtil.YMDHMS));
		if (i > 0) {
			return true;
		}
		return false;
	}

	private List<GetBondedProductInfoResult.YmtIdPic> GetIdPics(
			List<GetBondedProductInfoResult.YmtIdPic> pics) {
		List<GetBondedProductInfoResult.YmtIdPic> s = new ArrayList<GetBondedProductInfoResult.YmtIdPic>();
		if (!DataUtil.isNullOrEmpty(pics)) {
			s.addAll(pics);
		}
		return s;
	}

	private List<GetBondedProductInfoResult.YmtTradingItem> MergeTradingItem(
			List<GetBondedProductInfoResult.YmtTradingItem> tradingItems,
			List<GetBondedProductInfoResult.YmtTradingInfo> tradingInfos) {
		List<GetBondedProductInfoResult.YmtTradingItem> s = new ArrayList<GetBondedProductInfoResult.YmtTradingItem>();
		// System.out.println(tradingItems);
		if (!DataUtil.isNullOrEmpty(tradingItems)
				&& !DataUtil.isNullOrEmpty(tradingInfos)) {
			for (GetBondedProductInfoResult.YmtTradingItem item : tradingItems) {
				int iTradingId = item.getiTradingId();
				List<GetBondedProductInfoResult.YmtTradingInfo> infos = tradingInfos
						.stream().filter(x -> x.getiTradingId() == iTradingId)
						.collect(Collectors.toList());
				if (!DataUtil.isNullOrEmpty(infos)) {
					item.setYmt_TradingInfo(infos.get(0));
				}
				s.add(item);
			}
		}
		return s;
	}

	/**
	 * 存储过程的变量赋值
	 * 
	 * @param sp
	 */
	private void BuildArguments(Sp_GetBondedProductInfo sp) {
		sp.setSellerId(request.getUserId());
		sp.setConsiderCatalogStatus(1);
		sp.setNow(YMTDateUtil.getBeforeOrNextDay(0, YMTDateUtil.YMDTHMS_STRING));
		if (request.getCatalogStatus() == null
				|| request.getCatalogStatus() == LogisticsTypeEnum.Unknown
						.getValue()) {
			sp.setCatalogStatus(4);
			sp.setCatalogStatus2(5);
		} else {
			if (request.getCatalogStatus() == LogisticsTypeEnum.XloboBondedDelivery
					.getValue()) {
				sp.setBondedTimeout(10); // AppSetting配置文件中BondedTimeout的参数值
				sp.setCatalogStatus(5);
				sp.setCatalogStatus2(5);
				sp.setConsiderAcceptTime(1);
				sp.setConsiderBondedNoResult(1);
			} else {
				sp.setCatalogStatus(4);
				sp.setCatalogStatus2(4);
			}
		}
		if (request.getBondedArea() != null
				&& request.getBondedArea() != BondedAreaEnum.Unkown.getValue()) {
			sp.setConsiderBondedArea(1);
			sp.setBondedArea(request.getBondedArea());
		}
		if (!DataUtil.isNullOrEmpty(request.getOrderStates())) {
			sp.setTradingStatus(request.getOrderStates());
		}

		if (request.getDateType() == 1 && request.getStartDate() != null
				&& request.getEndDate() != null) {// 按照付款时间查询
			sp.setConsiderPaidTime(1);
			sp.setStartDate(request.getStartDate());
			sp.setEndDate(request.getEndDate());
		}

		if (request.getIsUploadIdCard() != null) { // 是否上传身份证
			sp.setConsiderIdPic(1);
			if (request.getIsUploadIdCard()) {
				sp.setNeedIdPic(1);
			} else {
				sp.setNeedIdPic(0);
			}
		}

		if (request.getDateType() == 2 && request.getStartDate() != null
				&& request.getEndDate() != null) {// 按照上传身份证时间查询
			sp.setConsiderIdPic(1);
			sp.setNeedIdPic(1);
			sp.setConsiderIdPicAddTime(1);
			sp.setStartDate(request.getStartDate());
			sp.setEndDate(request.getEndDate());
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetBondedProductInfo_001() {
		Logger.start(true, "以付款时间获取保税商品信息成功,测试BondedArea筛选");
		try {
			int userId = Integer.valueOf(EnvSetup.getData("SellerId"));
			// 只能传0,4,5 保税物流方式
			request.setBondedArea(BondedAreaEnum.HangZhou.getValue());
			// 线上固定4
			request.setCatalogStatus(LogisticsTypeEnum.BondedDelivery
					.getValue());
			// 时间筛选方式(1-付款时间 2-上传身份证时间), 线上固定1
			request.setDateType(1);
			// 线上固定17
			ArrayList<Integer> OrderStates = new ArrayList<Integer>();
			OrderStates.add(OrderStatusEnum.OrderEstablish.getValue());
			request.setOrderStates(OrderStates);
			String StartDate = YMTDateUtil.getBeforeOrNextDay(-100,
					YMTDateUtil.YMDTHMS_STRING);
			String EndDate = YMTDateUtil.getBeforeOrNextDay(-1,
					YMTDateUtil.YMDTHMS_STRING);
			request.setStartDate(StartDate);
			request.setEndDate(EndDate);
			request.setUserId(userId);
			// 发送请求
			getbondedproductinfocall.setData(request);
			getbondedproductinfocall.callService();
			// 数据检查
			Logger.verifyEquals(ECode.SUCCESS,
					getbondedproductinfocall.getCode(), "验证Code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetBondedProductInfo_002() {
		Logger.start(true, "以付款时间获取保税商品信息成功");
		try {
			int userId = Integer.valueOf(EnvSetup.getData("SellerId"));
			// 线上固定4
			request.setCatalogStatus(LogisticsTypeEnum.BondedDelivery
					.getValue());
			// 时间筛选方式(1-付款时间 2-上传身份证时间), 线上固定1
			request.setDateType(1);
			// 线上固定17
			ArrayList<Integer> OrderStates = new ArrayList<Integer>();
			OrderStates.add(OrderStatusEnum.SellerAccept.getValue());
			request.setOrderStates(OrderStates);
			String StartDate = YMTDateUtil.getBeforeOrNextDay(-40,
					YMTDateUtil.YMDTHMS_STRING);
			String EndDate = YMTDateUtil.getBeforeOrNextDay(1,
					YMTDateUtil.YMDTHMS_STRING);
			request.setStartDate(StartDate);
			request.setEndDate(EndDate);
			request.setUserId(userId);
			// 时间筛选方式(1-付款时间 2-上传身份证时间)
			request.setDateType(1);
			// 发送请求
			getbondedproductinfocall.setData(request);
			getbondedproductinfocall.callService();
			Logger.verifyEquals(ECode.SUCCESS,
					getbondedproductinfocall.getCode(), "验证Code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	// 接口查出来的数据要少
	public void Tc_GetBondedProductInfo_003() {
		Logger.start(true, "以付款时间获取保税商品信息成功");
		try {
			int userId = Integer.valueOf(EnvSetup.getData("SellerId"));
			// 只能传0,4,5 保税物流方式
			request.setBondedArea(BondedAreaEnum.NingBo.getValue());
			// 线上固定4
			request.setCatalogStatus(4);
			// 时间筛选方式(1-付款时间 2-上传身份证时间)， 线上固定1
			request.setDateType(1);
			// 线上固定17
			ArrayList<Integer> OrderStates = new ArrayList<Integer>();
			OrderStates.add(OrderStatusEnum.SellerAccept.getValue());
			request.setOrderStates(OrderStates);
			String StartDate = YMTDateUtil.getBeforeOrNextDay(-140);
			String EndDate = YMTDateUtil.getBeforeOrNextDay(1);
			request.setStartDate(StartDate);
			request.setEndDate(EndDate);
			request.setUserId(userId);
			// 发送请求
			getbondedproductinfocall.setData(request);
			getbondedproductinfocall.callService();
			// 数据检查
			Logger.verifyEquals(ECode.SUCCESS,
					getbondedproductinfocall.getCode(), "验证Code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	// fail 按传身份证查，接口数据比数据库查询要少
	public void Tc_GetBondedProductInfo_004() {
		Logger.start(true, "以上传身份证获取保税商品信息成功");
		try {
			int userId = Integer.valueOf(EnvSetup.getData("SellerId"));
			BondedAreaEnum area = BondedAreaEnum.HangZhou;
			// request.setBondedArea(BondedAreaEnum.GuangZhou);
			request.setBondedArea(area.getValue());
			// 线上固定4
			request.setCatalogStatus(4);
			// 线上固定1
			request.setDateType(1);
			// 线上固定17
			ArrayList<Integer> OrderStates = new ArrayList<Integer>();
			OrderStates.add(OrderStatusEnum.SellerAccept.getValue());
			request.setOrderStates(OrderStates);
			String StartDate = YMTDateUtil.getBeforeOrNextDay(-140);
			String EndDate = YMTDateUtil.getBeforeOrNextDay(1);
			request.setStartDate(StartDate);
			request.setEndDate(EndDate);
			request.setUserId(userId);
			// 发送请求
			getbondedproductinfocall.setData(request);
			getbondedproductinfocall.callService();
			// 数据检查
			Logger.verifyEquals(ECode.SUCCESS,
					getbondedproductinfocall.getCode(), "验证Code");
			verify();
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetBondedProductInfo_005() {
		Logger.start(true, "以付款时间获取保税商品信息成功,测试BondedArea筛选");
		try {

			PlaceOrderResp placeOrderResp = placeOrder10();

			Order order = placeOrderResp.getOrderList().get(0);

			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();
			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			// 支付订单
			orderCallService.orderPayRequest(userId, payAmount, tradingId);

			// 只能传0,4,5 保税物流方式
			request.setBondedArea(BondedAreaEnum.TianJin.getValue());
			// 线上固定4
			request.setCatalogStatus(LogisticsTypeEnum.BondedDelivery
					.getValue());
			// 时间筛选方式(1-付款时间 2-上传身份证时间), 线上固定1
			request.setDateType(1);
			// 线上固定17
			ArrayList<Integer> OrderStates = new ArrayList<Integer>();
			OrderStates.add(OrderStatusEnum.AccountPaid.getValue());
			request.setOrderStates(OrderStates);
			String StartDate = YMTDateUtil.getBeforeOrNextDay(-2,
					YMTDateUtil.YMDTHMS_STRING);
			String EndDate = YMTDateUtil.getBeforeOrNextDay(1,
					YMTDateUtil.YMDTHMS_STRING);

			request.setStartDate(StartDate);
			request.setEndDate(EndDate);
			request.setUserId(sellerId);
			// 发送请求
			getbondedproductinfocall.setData(request);
			getbondedproductinfocall.callService();
			// 数据检查
			Logger.verifyEquals(ECode.SUCCESS,
					getbondedproductinfocall.getCode(), "验证Code");

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_GetBondedProductInfo_006() {
		Logger.start(true, "使用宝付支付,以付款时间获取保税商品信息成功,测试BondedArea筛选");
		try {

			PlaceOrderResp placeOrderResp = placeOrder10();

			Order order = placeOrderResp.getOrderList().get(0);

			int userId = placeOrderResp.getUserId();
			int tradingId = placeOrderResp.getTradingId();
			int sellerId = order.getSellerId();

			BigDecimal payAmount = placeOrderResp.getPayAmount();

			OrderCallService orderCallService = new OrderCallService();

			int thirdTradingId = new OrderCallService().orderPayRequest(userId,
					BigDecimal.ZERO, tradingId, "13");

			PaymentProxyCallService.notifyCall("70",
					String.valueOf(thirdTradingId),
					payAmount.subtract(BigDecimal.ZERO).toString(), userId);

			SyncVerifyService.getSyncResult(order.getOrderId());

			// 只能传0,4,5 保税物流方式
			request.setBondedArea(BondedAreaEnum.TianJin.getValue());
			// 线上固定4
			request.setCatalogStatus(LogisticsTypeEnum.BondedDelivery
					.getValue());
			// 时间筛选方式(1-付款时间 2-上传身份证时间), 线上固定1
			request.setDateType(1);
			// 线上固定17
			ArrayList<Integer> OrderStates = new ArrayList<Integer>();
			OrderStates.add(OrderStatusEnum.AccountPaid.getValue());
			request.setOrderStates(OrderStates);
			String StartDate = YMTDateUtil.getBeforeOrNextDay(-2,
					YMTDateUtil.YMDTHMS_STRING);
			String EndDate = YMTDateUtil.getBeforeOrNextDay(1,
					YMTDateUtil.YMDTHMS_STRING);

			request.setStartDate(StartDate);
			request.setEndDate(EndDate);
			request.setUserId(sellerId);
			// 发送请求
			getbondedproductinfocall.setData(request);
			getbondedproductinfocall.callService();
			// 数据检查
			Logger.verifyEquals(ECode.SUCCESS,
					getbondedproductinfocall.getCode(), "验证Code");

			verify();

		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}